<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>添加管理员</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">

		<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
	</head>

	<body>
		<div style="margin: 15px;">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				<legend>添加公司管理员</legend>
			</fieldset>

			<form class="layui-form" action="" style="padding-left: 100px;padding-right: 100px">
				<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-block">
						<input type="text" id="username" lay-verify="required" autocomplete="off" placeholder="请输入用户名" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-block">
						<input type="text" id="password" lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">电话</label>
					<div class="layui-input-block">
						<input type="text" id="phone" lay-verify="phone" autocomplete="off" placeholder="请输入电话" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">真实姓名</label>
					<div class="layui-input-block">
						<input type="text" id="realname" lay-verify="required" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">添加日期</label>
					<div class="layui-input-block">
						<input type="text" id="createTime"  lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
					</div>
				</div>


				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
		<script type="text/javascript" src="plugins/layui/layui.js"></script>

		<script>



			layui.use(['form', 'laydate'], function() {
				var form = layui.form(),
					layer = layui.layer,
					laydate = layui.laydate,
						$= layui.jquery;
				//自定义验证规则
				form.verify({
				});

				//监听提交
				form.on('submit(demo1)', function(data) {

					var username=$('#username').val();
					var password=$('#password').val();
					var phone=$('#phone').val();
					var realname=$('#realname').val();
					var createTime=$('#createTime').val();

                    //通过from表单取值，然后提交
					$.post("/add_company",{username:username,password:password,phone:phone,
						realname:realname,createTime:createTime
					},function(result){
						if(result.status==="success"){
							layer.msg('添加成功，请到公司管理员列表查看!', {
								icon: 1,
								time: 1000
							});
						}else{
							layer.msg('添加失败!', {
								icon: 1,
								time: 1000
							});
						}
					});
					return false;
				});
			});
		</script>
	</body>

</html>